package RLK_MICRO;

import java.io.IOException;
import java.io.InputStream;

public class Example_02 {
    public byte[] getData(final String url) throws IOException {
        ContentConnection connection = (ContentConnection) Connector.open(url); // Resource allocated
        try {
            InputStream iStrm = connection.openInputStream();
            int length = (int) connection.getLength();
            if (length > 0) {
                byte data[] = new byte[length];
                iStrm.read(data);
                return data;
            }
            return EMPTY;
        } finally {
            connection.close(); // Resource released
        }
    }
}
